﻿#include "filereader.h"
#include <QMessageBox>
#include <QFileDialog>
#include <QApplication>
#include <QDebug>

FileReader::FileReader(QString str, QObject *parent)
    : QObject{parent}
{

    QString filePath = QFileDialog::getOpenFileName(static_cast<QWidget*>(parent), u8"读取文件", QApplication::applicationDirPath(), str);
    if (!filePath.isEmpty()) m_FilePath = filePath;
}



bool FileReader::isFileValid()
{
    QFileInfo fi(m_FilePath);

    if (fi.exists()) return true;
    else {
        QMessageBox::warning(static_cast<QWidget*>(parent()), u8"警告", u8"文件:\"" + m_FilePath + u8"\"不存在!");
        return false;
    }
}

QString FileReader::getFilePath()
{
    return m_FilePath;
}

